package MULE.Model;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import javax.swing.JButton;

/**
 * Represents a sign post for a town establishment.
 * 
 * @author jstep
 */
public class EstablishmentSign extends JButton {

	private static final int SIGN_WIDTH = 300;
	private static final int SIGN_HEIGHT = 60;

	private String name;
	private Color fontColor, paintColor;

	/**
	 * Creates a new sign with the given background color and name.
	 * 
	 * @param name
	 *            Text to write on sign.
	 * @param paintColor
	 *            Background color of the sign.
	 */
	public EstablishmentSign(String name, Color fontColor, Color paintColor) {
		this.name = name;
		this.fontColor = fontColor;
		this.paintColor = paintColor;
		Dimension size = new Dimension(SIGN_WIDTH, SIGN_HEIGHT);
		this.setMinimumSize(size);
		this.setPreferredSize(size);
		this.setMaximumSize(size);
	}

	/**
	 * JButton's overridden paint method. Draws the sign.
	 * 
	 * @param g
	 *            The object on which to draw the sign.
	 */
	public void paintComponent(Graphics g) {
		// Draw sign.
		g.setColor(paintColor);
		g.fillRect(0, 0, SIGN_WIDTH, SIGN_HEIGHT);
		// Draw text.
		g.setColor(fontColor);
		g.setFont(new Font("Sans Serif", Font.BOLD, 15));
		g.drawString(name.toUpperCase(), 15, 37);
	}
}
